/*************************************************************************
	> File Name: trie.cpp
	> Author: 
	> Mail: 
	> Created Time: 日  5/ 9 11:01:38 2021
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define BASE 26

typedef struct Node {
    int flag;
    struct Node *next[26];
} Node;

Node *getNewNode() {
    Node *p = (Node *)malloc(sizeof(Node));
    p->flag = 0;
    memset(p->next, 0, sizeof(Node *) * BASE);
    return p;
}

void insert(Node *root, const char *str) {
    Node *p = root;
    for (int i = 0; str[i]; i++) {
        int ind = str[i] - 'a';
        if (p->next[ind] == NULL) p->next[ind] = getNewNode();
        p = p->next[ind];
    }
    p->flag = 1;
    return ;
}

int find(Node *root, const char *str) {
    Node *p = root;
    for (int i = 0; str[i]; i++) {
        p = p->next[str[i] - 'a'];
        if (p == NULL) return 0;
    }
    return p->flag;
}

void clear(Node *root) {
    if (root == NULL) return ;
    for (int i = 0; i < BASE; i++) {
        clear(root->next[i]);
    }
    free(root);
    return;
}

int main() {
    int op;
    char str[100];
    Node *root = getNewNode();
    while (~scanf("%d%s", &op, str)) {
        switch(op) {
            case 1: {
                printf("insert %s to trie\n", str);
                insert(root, str);
            } break;
            case 2: {
                printf("find %s from trie = %d\n", str, find(root, str));
            } break;
        }
    }
    return 0;
}
